package db;

import java.util.*;
import javax.swing.table.AbstractTableModel;

//////////////////////////////////////////////////////////////////////////
//// DBTableModel
/**

@author Ivan Jeukens
@version v 0.1 28/02/2002
*/
public class DBTableModel extends AbstractTableModel {

    public DBTableModel() {
        super();
        _infoList = new LinkedList();
    }

    ///////////////////////////////////////////////////////////////////
    ////                         public methods                    ////

    public void add(dbInfoSummary sum) {
        _infoList.add(sum);
    }

    public int getColumnCount() {
        return _columnNames.length;
    }

    public String getColumnName(int col) {
        return _columnNames[col];
    }
     
    public int getRowCount() {
        if(_infoList == null) return 0;
        return _infoList.size();
    }

    public Object getValueAt(int row, int col) {
        dbInfoSummary sum = (dbInfoSummary) _infoList.get(row);
        switch(col) {
            case 0: {
                return (String) sum.getName();
            }

            case 1: {
                return (String) sum.getURL().toString();
                //return (String) info.getName();
            }
        }
	return "";
    }
  
    public dbInfoSummary getSummaryAt(int row) {
        return (dbInfoSummary) _infoList.get(row);
    }

    public Class getColumnClass(int col) {
        switch(col) {
	    case 0: return String.class;
	    case 1: return String.class;
	}
	return null;
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private methods                   //// 

    ///////////////////////////////////////////////////////////////////
    ////                         private variables                 ////

    private String [] _columnNames = { "name", "url" };

    private LinkedList _infoList;

    private int [] _tableIndex;
    private int _indexSize;
}
